@echo off
echo ============================================
echo 测试修复后的认证和API访问功能
echo ============================================

set BASE_URL=http://localhost:8081

echo.
echo [1] 测试健康检查端点
curl -X GET "%BASE_URL%/api/health" -H "Content-Type: application/json"

echo.
echo.
echo [2] 测试信息端点
curl -X GET "%BASE_URL%/api/info" -H "Content-Type: application/json"

echo.
echo.
echo [3] 测试根路径
curl -X GET "%BASE_URL%/api/" -H "Content-Type: application/json"

echo.
echo.
echo [4] 测试用户注册
curl -X POST "%BASE_URL%/api/auth/register" ^
  -H "Content-Type: application/json" ^
  -d "{\"username\":\"testuser\",\"password\":\"test123\",\"name\":\"Test User\",\"email\":\"test@example.com\"}"

echo.
echo.
echo [5] 测试用户登录
curl -X POST "%BASE_URL%/api/auth/login" ^
  -H "Content-Type: application/json" ^
  -d "{\"username\":\"testuser\",\"password\":\"test123\"}"

echo.
echo.
echo [6] 测试药品API（无需认证）
curl -X GET "%BASE_URL%/api/drugs" -H "Content-Type: application/json"

echo.
echo.
echo [7] 测试客户API（无需认证）
curl -X GET "%BASE_URL%/api/customers" -H "Content-Type: application/json"

echo.
echo.
echo [8] 测试添加客户（无需认证）
curl -X POST "%BASE_URL%/api/customers" ^
  -H "Content-Type: application/json" ^
  -d "{\"name\":\"张三\",\"contact\":\"13800138000\",\"address\":\"北京市朝阳区\"}"

echo.
echo.
echo ============================================
echo 测试完成！
echo ============================================
pause 